<template>
  <el-dropdown trigger="click" @command="changeLanguage">
    <!-- 这里必须加一个div -->
    <div>
      <svg-icon style="color: #fff; font-size: 20px;background-color: red;" icon-class="language" />
    </div>
    <template v-slot:dropdown>
       <el-dropdown-menu >
         <el-dropdown-item command="zh" :disabled="'zh' === $i18n.locale"
           >中文</el-dropdown-item
         >
         <el-dropdown-item command="en" :disabled="'en' === $i18n.locale"
           >en</el-dropdown-item
         >
       </el-dropdown-menu>     
    </template>
  </el-dropdown>
</template>

<script>
import Cookie from "js-cookie";
export default {
  methods: {
    changeLanguage(type) {
      // 切换多语言类型
      Cookie.set("language", type);
      this.$i18n.locale = type;
      this.$message.success("切换语言成功");
    },
  },
};
</script>

<style>
</style>
